<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>

<head>
    <base href="<%=basePath%>"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css" />
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<style>
    /*定义类名为.thead-blue的样式*/
    .thead-blue {
        color: #fff;
        font-weight: bold;
        background-color: #337ab7;
    }
</style>
<body>
<!-- 搜索 -->
<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">已发消息搜索</h4>
    </div>
    <div class="panel-body">
        <form action="dxxdate/pageDuanxiaoxi" id="seachform" method="post"
              class="form-horizontal" role="form">
            <div class="form-group">
                <div class="col-md-5">
                    <label for="biaoti" class="col-md-4 control-label">消息主题</label>
                    <div class="col-md-8">
                        <input type="text" id="biaoti" name="biaoti" class="form-control"
                               placeholder="请输入消息主题">
                        <input type="hidden" name="page" id="page" value="${pageBean.page }">
                        <input type="hidden" name="pageSize" id="pageSize" value="${pageBean.pageSize }">
                    </div>
                </div>
                <div class="col-md-5">
                    <label for="jieshouren" class="col-md-4 control-label">接收人</label>
                    <div class="col-md-8">
                        <input type="hidden" id="jieshouren" name="jieshouren">
                        <div class="input-group">
                            <input type="text" id="empName" name="empName"
                                   readonly="readonly" class="form-control" placeholder="请选择员工"
                                   value=""> <span class="input-group-btn">
									<button class="btn btn-info" type="button" data-toggle="modal"
                                            data-target="#selectempModal">请选择</button>
								</span>
                        </div>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="col-md-12">
                        <a type="button" href="view/xx/sendxiaoxi.jsp" class="btn btn-info">发送消息</a>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-5">
                    <label for="startDate" class="col-md-4 control-label">开始时间</label>
                    <div class="col-md-8">
                        <input type="date" id="startDate" name="startDate"
                               class="form-control">
                    </div>
                </div>
                <div class="col-md-5">
                    <label for="endDate" class="col-md-4 control-label">结束时间</label>
                    <div class="col-md-8">
                        <input type="date" id="endDate" name="endDate"
                               class="form-control">
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="col-md-12">
                        <button type="submit" class="btn btn-success">搜索消息</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- 列表 -->
<div class="panel panel-primary">
    <table class="table table-bordered table-hover">
        <thead>
        <tr class="thead-blue" align="center">
            <td>消息标题</td>
            <td>发送时间</td>
            <td>接收人</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
          <c:forEach items="${duanxiaoxiList.data}" var="duanxiaoxi">
              <tr align="center">
                  <td>${duanxiaoxi.biaoti}</td>
                  <td>${duanxiaoxi.createDate}</td>
                  <td>
                      <c:forEach items="${duanxiaoxi.xiaoxijieshou}" var="jieshou">
                          <c:if test="${jieshou.isread=='1'}">
                              <span class="text-success">
                                      ${jieshou.employee.empName}
                              </span>
                          </c:if>
                          <c:if test="${jieshou.isread=='0'}">
                              <span class="text-danger">
                                      ${jieshou.employee.empName}
                              </span>
                          </c:if>
                      </c:forEach>
                  </td>
                  <td>
                      <a type="button" href="duanxiaoxi/xxjsxq?oid=${duanxiaoxi.oid}" class="btn btn-info btn-xs">查看详情</a>
                  </td>
              </tr>
          </c:forEach>
        </tbody>
    </table>
</div>

<!-- 分页 -->
<div class="input-group col-md-8 col-md-offset-3">
    <div class="row">
        <div class="btn-group">
            <button onclick="gotoPage(1,${duanxiaoxiList.pageSize})" class="btn btn-primary" type="button">首页</button>
            <c:if test="${duanxiaoxiList.page==1 }">
                <button class="btn btn-primary disabled" type="button">上一页</button>
            </c:if>
            <c:if test="${duanxiaoxiList.page>1 }">
                <button onclick="gotoPage(${duanxiaoxiList.page-1},${duanxiaoxiList.pageSize})" class="btn btn-primary"
                        type="button">上一页
                </button>
            </c:if>

            <button class="btn btn-primary disabled" type="button">
                当前第${duanxiaoxiList.page}/${duanxiaoxiList.pageCount}页
            </button>

            <div class="btn-group">
                <button type="button" class="btn btn-primary dropdown-toggle"
                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    每页显示${duanxiaoxiList.pageSize}条 <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li><a href="javascript:gotoPage(1,5)">每页显示5条</a></li>
                    <li><a href="javascript:gotoPage(1,10)">每页显示10条</a></li>
                    <li><a href="javascript:gotoPage(1,15)">每页显示15条</a></li>
                    <li><a href="javascript:gotoPage(1,20)">每页显示20条</a></li>
                </ul>
            </div>

            <button class="btn btn-primary disabled" type="button">共${duanxiaoxiList.rowCount}条记录</button>

            <c:if test="${duanxiaoxiList.page==duanxiaoxiList.pageCount }">
                <button class="btn btn-primary disabled" type="button">下一页</button>
            </c:if>
            <c:if test="${duanxiaoxiList.page<duanxiaoxiList.pageCount }">
                <button onclick="gotoPage(${duanxiaoxiList.page+1},${duanxiaoxiList.pageSize})" class="btn btn-primary"
                        type="button">下一页
                </button>
            </c:if>
            <button onclick="gotoPage(${duanxiaoxiList.pageCount },${duanxiaoxiList.pageSize})" class="btn btn-primary"
                    type="button">尾页
            </button>
        </div>
    </div>
</div>

<%@include file="../modal/selectemp.jsp" %>
</body>

<script type="text/javascript">
    function setempvalue(eid, empName) {
        $("#jieshouren").val(eid);
        $("#empName").val(empName);
    }
    function gotoPage(page, pageSize) {
        document.location.href = "duanxiaoxi/listDuanxiaoxi?page=" + page + "&pageSize=" + pageSize;
    }
</script>

</html>
